package com.xiaoxu.intranetweb.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理器
 *
 * @author Yuzhe Ma
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(value = CustomAnnotateUtil.CheckPermissionAspect.PermissionDeniedException.class)
    public ResponseEntity businessExceptionHandler(HttpServletRequest httpServletRequest, CustomAnnotateUtil.CheckPermissionAspect.PermissionDeniedException e) {
        return new ResponseEntity(SzResult.error(e.getMessage()), HttpStatus.OK);
    }
}